package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.Callable;

public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Person p = new Person("刘苍松", 55);
        System.out.println(p);

        Class cls = Class.forName("reflect.Person");
        Constructor c = cls.getConstructor(String.class, int.class);
        Object o = c.newInstance("王克晶", 18);
        System.out.println(o);
    }
}
